<template>
  <div>
    <p :style="{opacity}">React真难啊学不会</p>
    <button @click="destroy">干掉他 我们一起学vue</button>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      opacity: 1,
      timer: null,
    };
  },
  methods: {
    destroy(){
      this.$destroy()
    }
  },
  mounted(){
    console.log(this);
    this.timer = setInterval(()=>{
      this.opacity -= 0.1;
       if (this.opacity <= 0) {
        this.opacity = 1;
      }
      console.log(1);
    },200)
  },
  beforeDestroy(){
    clearInterval(this.timer);
  }
};
</script>

<style></style>
